<?php
/*************************************************************************************
 *
 *	FileName: /edp/module/ajax_error_report/header_php.php
 *	Desc    : This file is to add error report .
 *	Author  : Bo
 *	Date    : 2009-11-14
 *
 *************************************************************************************/
    

/*data 为 serializeArray() */


$userDAO = GetUserDAO();

$shopDAO = GetShopDAO();
	
if($_GET['tiny'] == '1'){ 
	
	if( GetLoginUserID() != false ){
		
	  $userArr = $userDAO->GetUserByID( GetLoginUserID() );
		
	  if($userArr){
	  	$_GET['errorName'] = $userArr['nick'];
	  	$_GET['errorEmail'] = $userArr['email'];	  	  	
	  }
	} 
	
	echo json_encode($_GET);
	
	
}else if($_GET['tiny'] == '2'){
	
	if($_POST['action'] == 'addErrorReport'){

		if(edp_isset_session('userid')){
			
			$userID = edp_getsession('userid');
			
		}else{
			$userID = '0';
		}
		
		if( IsParaOK() == false )
		{
			echo_validation_message();
			exit();
		}
		
		if(!edp_is_empty_string($_POST['errorName'])&&!edp_is_empty_string($_POST['errorEmail'])&&
		   !edp_is_empty_string($_POST['errorID'])&&!edp_is_empty_string($_POST['errorDescription'])&&
		   !edp_is_empty_string($_POST['errorType'])){	
		   	
			$userName = edp_db_input(trim($_POST['errorName']));
			$userEmail = edp_db_input(trim($_POST['errorEmail']));
			$errorID =edp_db_input(trim($_POST['errorID']));
			$description =edp_db_input(trim($_POST['errorDescription']));
			$errorType = edp_db_input(trim($_POST['errorType']));	
			$userDAO->AddErrorReport($userName,$userEmail,$userID,$description,$errorID,$errorType);		   			 	
		}		
	}
}

?>